package com.example.carowners;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.TextView;

public class CarOwnersWeibaoYuyue extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_car_owners_weibao_yuyue);

        //维保类型适配器
        Spinner sp_weibaoleixing = findViewById(R.id.sp_weibaoleixing);
        String[] weibao_leixing = new String[]{"常规保养","车辆维修"};
        ArrayAdapter leixing_Adapter = new ArrayAdapter(this,R.layout.item_weibaoleixing,weibao_leixing);
        sp_weibaoleixing.setAdapter(leixing_Adapter);
        sp_weibaoleixing.setSelection(0);

        //维修方案适配器
        Spinner sp_weixiufangan = findViewById(R.id.sp_weixiufangan);
        String[] weibao_fangan = new String[]{"更换零件","维修类目","单项价格","维修总价","维修周期"};
        ArrayAdapter fangan_Adapter = new ArrayAdapter(this,R.layout.item_weibaoleixing,weibao_fangan);
        sp_weixiufangan.setAdapter(fangan_Adapter);
        sp_weixiufangan.setSelection(0);

        TextView tv_weixiufangan = findViewById(R.id.tv_weixiufangan);

        sp_weibaoleixing.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

                if(position==1){
                    tv_weixiufangan.setVisibility(View.VISIBLE);
                    sp_weixiufangan.setVisibility(View.VISIBLE);
                }

            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });

        //点击提交按钮进入支付页面
        Button bt_tijiaoweibaoyuyue = findViewById(R.id.bt_tijiaoweibaoyuyue);
        bt_tijiaoweibaoyuyue.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(CarOwnersWeibaoYuyue.this,PaySuccess.class));
            }
        });

        //点击维保历史按钮进入维保历史界面
        Button bt_weibaohistoryinweibaoyuyue = findViewById(R.id.bt_weibaohistoryinweibaoyuyue);
        bt_weibaohistoryinweibaoyuyue.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(CarOwnersWeibaoYuyue.this,CarOwnersWeibaoHistory.class));
            }
        });


    }
}